
using JTZY.Model.Business;
using JTZY.Model.Product;
using Newtonsoft.Json.Linq;

namespace JTZY.Model.Order.Dto
{
    /// <summary>
    /// 退货单表查询对象
    /// </summary>
    public class CorecmsbillaftersalesQueryDto : PagerInfo
    {
        public string OrderId { get; set; }
        public DateTime? BeginCreateTime { get; set; }
        public DateTime? EndCreateTime { get; set; }
        public long userId { get; set; }
        public string filter { get; set; }
        public string SourceType { get; set; }
        public int? Status { get; set; }
    }

    public class AfterStockQueryDto : PagerInfo
    {
        public string OrderId { get; set; }
        public DateTime? BeginCreateTime { get; set; }
        public DateTime? EndCreateTime { get; set; }
        public long userId { get; set; }
        public string filter { get; set; }
        public string SourceType { get; set; }

        public int? Status { get; set; }
    }

    /// <summary>
    /// 退货单表输入输出对象
    /// </summary>
    public class CorecmsbillaftersalesDto
    {
        [ExcelColumn(Name = "售后单id")]
        [ExcelColumnName("售后单id")]
        public string AftersalesId { get; set; }

        [ExcelColumn(Name = "订单ID")]
        [ExcelColumnName("订单ID")]
        public string OrderId { get; set; }

        [ExcelColumn(Name = "用户ID")]
        [ExcelColumnName("用户ID")]
        public int UserId { get; set; }

        [ExcelColumn(Name = "售后类型")]
        [ExcelColumnName("售后类型")]
        public int Type { get; set; }

        [ExcelColumn(Name = "退款金额")]
        [ExcelColumnName("退款金额")]
        public decimal RefundAmount { get; set; }

        [ExcelColumn(Name = "状态")]
        [ExcelColumnName("状态")]
        public int Status { get; set; }

        [ExcelColumn(Name = "退款原因")]
        [ExcelColumnName("退款原因")]
        public string Reason { get; set; }

        [ExcelColumn(Name = "卖家备注，如果审核失败了，会显示到前端")]
        [ExcelColumnName("卖家备注，如果审核失败了，会显示到前端")]
        public string Mark { get; set; }

        [ExcelColumn(Name = "提交时间", Format = "yyyy-MM-dd HH:mm:ss", Width = 20)]
        [ExcelColumnName("提交时间")]
        public DateTime? CreateTime { get; set; }

        [ExcelColumn(Name = "更新时间", Format = "yyyy-MM-dd HH:mm:ss", Width = 20)]
        [ExcelColumnName("更新时间")]
        public DateTime? UpdateTime { get; set; }

        [ExcelColumn(Name = "退货方式")]
        [ExcelColumnName("退货方式")]
        public string ReMethod { get; set; }

        [ExcelColumn(Name = "0销售订单  1 采购订单")]
        [ExcelColumnName("0销售订单  1 采购订单")]
        public string SourceType { get; set; }

        public string RetReasons { get; set; }

        /// <summary>
        /// 退款状态
        /// </summary>
        public int PayStatus { get; set; }
        /// <summary>
        /// 退款时间
        /// </summary>
        public DateTime? PayTime { get; set; }
        /// <summary>
        /// 售后进度
        /// </summary>
        public int AfterProgress { get; set; }

        [ExcelColumn(Name = "售后类型")]
        public string TypeLabel { get; set; }

        [ExcelIgnore]
        public List<Corecmsbillaftersalesitem> CorecmsbillaftersalesitemNav { get; set; }
        [ExcelIgnore]

        public List<Corecmsbillaftersalesimages> Images { get; set; }
        [ExcelIgnore]
        public Corecmsuser User { get; set; }

        public DateTime? ShipTime { get; set; }

        /// <summary>
        /// 客户退货单
        /// </summary>
        public string OldaftersalesId { get; set; }

    }

    public class CorecmsbillaftersalesExDto
    {
        [ExcelColumn(Name = "售后单号")]
        [ExcelColumnName("售后单号")]
        public string AftersalesId { get; set; }

        [ExcelColumn(Name = "订单号")]
        [ExcelColumnName("订单号")]
        public string OrderId { get; set; }

        [ExcelColumn(Name = "申请时间", Format = "yyyy-MM-dd HH:mm:ss", Width = 20)]
        [ExcelColumnName("提交时间")]
        public DateTime? CreateTime { get; set; }

        [ExcelColumn(Name = "客户")]
        [ExcelColumnName("客户")]
        public string UserName { get; set; }

        /// <summary>
        /// 退款状态
        /// </summary>
        [ExcelColumn(Name = "退款状态")]
        [ExcelColumnName("退款状态")]
        public string PayStatus { get; set; }
        /// <summary>
        /// 退款时间
        /// </summary>
        [ExcelColumn(Name = "退款时间", Format = "yyyy-MM-dd HH:mm:ss", Width = 20)]
        [ExcelColumnName("退款时间")]
        public DateTime? PayTime { get; set; }


        [ExcelColumn(Name = "退货方式")]
        [ExcelColumnName("退货方式")]
        public string ReMethod { get; set; }

        [ExcelColumn(Name = "商品名称")]
        [ExcelColumnName("商品名称")]
        public string Addon { get; set; }

        [ExcelColumn(Name = "商品编码")]
        [ExcelColumnName("商品编码")]
        public string Sn { get; set; }

        [ExcelColumn(Name = "商品69码")]
        [ExcelColumnName("商品69码")]
        public string BarCode { get; set; }


        [ExcelColumn(Name = "数量")]
        [ExcelColumnName("数量")]
        public decimal Nums { get; set; }

        [ExcelColumn(Name = "金额")]
        [ExcelColumnName("金额")]
        public decimal Amount { get; set; }


        [ExcelColumn(Name = "订单状态")]
        [ExcelColumnName("订单状态")]
        public string StatusStr
        {
            get
            {
                if (Status == 0)
                {
                    return "商家待审核";
                }
                else if (AfterProgress == 1)
                {
                    return "商家待收货";
  }
                else if (AfterProgress == 2)
                {
                    return "商家待收货";
  }
                else if (AfterProgress == 3)
                {
                    return "已完成";
  }
                else if (AfterProgress == 4)
                {
                    return "退货待退款";
  }
                else if (AfterProgress == 5)
                {
                    return "商家待发货";
  }
                else if (AfterProgress == 6)
                {
                    return "厂家待收货";
  }
                else
                {
                    return "已关闭";
  }
            }
        }

        [ExcelIgnore]
        public int Status { get; set; }

        [ExcelIgnore]
        public int AfterProgress { get; set; }

    }


    /// <summary>
    ///     前端提交售后单提交参数
    /// </summary>
    public class ToAddBillAfterSalesPost
    {
        /// <summary>
        ///     订单编号
        /// </summary>
        public string orderId { get; set; }

        /// <summary>
        ///     是否收到退货，1未收到退货，不会创建退货单，2收到退货，会创建退货单,只有未发货的商品才能选择未收到货，只有已发货的才能选择已收到货
        /// </summary>
        public int type { get; set; } = 0;

        public string reMethod { get; set; } = "0";
        public string retReasons { get; set; } = "0";
        /// <summary>
        ///     如果是退款退货，退货的明细 以 [[order_item_id=>nums]]的二维数组形式传值
        /// </summary>
        public JArray items { get; set; }

        /// <summary>
        ///     上传图集
        /// </summary>
        public string images { get; set; }

        /// <summary>
        ///     备注
        /// </summary>
        public string reason { get; set; }

        /// <summary>
        ///     金额
        /// </summary>
        public decimal refund { get; set; } = 0;

        public List<Billaftersaledetails> details { get; set; }

        public string sourceType { get; set; }
        public long userId { get; set; }
        public string Mark { get; set; }
        public string AftersalesId { get; set; }
        public decimal refundAmount { get; set; } = 0;
    }

    public class ToAddUnsaleAfterSalesPost
    {
        /// <summary>
        ///     是否收到退货，1未收到退货，不会创建退货单，2收到退货，会创建退货单,只有未发货的商品才能选择未收到货，只有已发货的才能选择已收到货
        /// </summary>
        public int type { get; set; } = 0;

        public string reMethod { get; set; } = "0";
        public string retReasons { get; set; } = "0";
        /// <summary>
        ///     如果是退款退货，退货的明细 以 [[order_item_id=>nums]]的二维数组形式传值
        /// </summary>
        public List<Prodinfo> details { get; set; }

        /// <summary>
        ///     上传图集
        /// </summary>
        public string images { get; set; }

        /// <summary>
        ///     备注
        /// </summary>
        public string reason { get; set; }

        /// <summary>
        ///     金额
        /// </summary>
        public decimal refund { get; set; } = 0;

        public List<Corecmsbillaftersalesitem> items { get; set; }

        public string sourceType { get; set; }
        public long userId { get; set; }
        public string Mark { get; set; }
        public string AftersalesId { get; set; }
        public decimal refundAmount { get; set; } = 0;
    }
    public class Billaftersaledetails
    {

        public string AftersalesId { get; set; }

        public int? ProductId { get; set; }

        public string SnCode { get; set; }



    }
}